import axios from '../request';
import { AddProject, ProjectList, SettingType } from '../model/project';

// 获取展览动态分页
export const projectLogs = (params: ProjectList) => {
  return axios.get<any>(
    `api/project/logs/${params.projectId}?value=${params.value ? params.value : ''}&PageNo=${params.PageNo}&PageSize=${
      params.PageSize
    }`,
    {},
  );
};
//创建展览
export const addProject = (params: AddProject) => {
  return axios.post<any>(`api/project`, params);
};
//项目角色
export const projectRole = (projectId: number | string) => {
  return axios.get<any>(`api/project/role/${projectId}`, {});
};
//按字典更新数据
export const updateProject = (params: any, projectId: number | string) => {
  return axios.patch<any>(`/api/project/${projectId}`, params);
};
//项目星标
export const asterisk = (projectId: number | string) => {
  return axios.post<any>(`api/project/asterisk/${projectId}`, {});
};
//获取项目分页数据
export const projectLists = (id: number | string) => {
  return axios.get<any>(`api/exhibition/projects/${id}`, {});
};
//获取项目类型数量
export const typeNumber = (value?: string) => {
  return axios.get<any>(`api/project/numbers${value ? '?value=' + value : ''}`, {});
};
//项目概览
export const overview = (projectId: number | string) => {
  return axios.get<any>(`api/project/overview/${projectId}?logSize=3`, {});
};
//项目成员
export const members = (projectId: number | string, companyId?: string | number, name?: string) => {
  return axios.get<any>(`api/project/members/${projectId}?companyId=${companyId}&name=${name ? name : ''}`, {});
};
export const groups = (projectId: number | string, name?: string) => {
  return axios.get<any>(`api/project/groups/${projectId}?&name=${name ? name : ''}`, {});
};
//更改项目角色
export const setrole = (projectId: number | string, userId: number, role: number) => {
  return axios.put<any>(`api/project/role/${projectId}/${userId}/${role}`, {});
};
//更改项目角色
export const delUser = (projectId: number | string, userId: number, role: number) => {
  return axios.delete<any>(`api/project/member/${projectId}/${userId}`, {});
};
//审核项目成员
export const auditMember = (projectId: number | string, userId: number, role?: number) => {
  return axios.put<any>(`api/project/auditMember/${projectId}/${userId}`, {});
};
//项目详情
export const projectDetail = (projectId: number | string) => {
  return axios.get<any>(`api/project/detail/${projectId}`, {});
};
//移交项目
export const transfer = (projectId: number | string, userId: number) => {
  return axios.put<any>(`api/project/transfer/${projectId}/${userId}`, {});
};
//获取项目配置
export const settings = (projectId: number | string, type?: number) => {
  return axios.get<any>(`api/project/settings/${projectId}${type ? '?type=' + type : ''}`, {});
};
//获取项目回收站分页数据
export const recycle = (parmas: ProjectList) => {
  return axios.get<any>(`api/project/recycle`, parmas);
};
//恢复回收站项目
export const recoveryProjact = (parmas: string) => {
  return axios.put<any>(`api/project/recovery/${parmas}`);
};
//删除项目
export const projectDisable = (projectId: number | string) => {
  return axios.put<any>(`api/project/disable/${projectId}`, {});
};
//保存设置
export const addsettings = (projectId: number | string, parmas: Array<SettingType>) => {
  return axios.post<any>(`api/project/settings/${projectId}`, parmas);
};
//发布项目
export const publishProjact = (parmas: string | number) => {
  return axios.put<any>(`api/project/publish/${parmas}`);
};
//撤回项目
export const withdrawnProjact = (parmas: string | number) => {
  return axios.put<any>(`api/project/withdrawn/${parmas}`);
};
//获取操作项目列表
export const projectOpers = (parmas: string | number) => {
  return axios.get<any>(`api/project/opers/${parmas}`);
};
//获取封面
export const projectImg = (parmas: string | number) => {
  return axios.get<any>(`api/project/common/${parmas}`);
};
//获取项目点赞状态
export const templateIsFollow = (refId: string | number) => {
  return axios.get<any>(`api/interact/isFollow?RefType=3&RefId=${refId}`);
};

//获取展览信息
export const projectRoutin = (parmas: string | number) => {
  return axios.get<any>(`api/template/routin/${parmas}`);
};
// status 全部-1 进行中1 待审核7 平台审核2 已发布3
// export const projectManage = (parmas: ProjectManageType) => {
//   return axios.get<any>(`api/project/manage`, parmas);
// };

// //获取展览管理数量
// export const projectStatus = (parmas: ProjectManageType) => {
//   return axios.get<any>(`api/project/status`, parmas);
// };

//获取单位管理中展览详情
export const manageDetail = (projectId: number | string, logoSize: number) => {
  return axios.get<any>(`api/project/manageDetail/${projectId}?logoSize=${logoSize}`);
};

interface UserRejectedType {
  value: number;
  text: string;
}
//用户驳回
export const userRejected = (parmas: UserRejectedType) => {
  return axios.put<any>(`api/project/userRejected`, parmas);
};
//用户通过
export const userApproved = (id: number | string) => {
  return axios.put<any>(`api/project/userApproved/${id}`, {});
};
//变更创建人
export const creatorProject = (projectId: number | string, userId: number) => {
  return axios.put<any>(`api/project/creator/${projectId}/${userId}`, {});
};
//搜索相关单位
export const templateCompanys = (name: string, pagesize: number) => {
  return axios.get<any>(`/api/project/companys?name=${name}&pageSize=${pagesize}`);
};
//搜索能配置的展览
export const flutTemplateList = (templateId: string) => {
  return axios.get<any>(`/api/project/relateTemplate/${templateId}`);
};
//获取模板相关项目
export const templateProject = (id: string | number, pagesize: number) => {
  return axios.get<any>(`api/project/template/${id}?pageSize=${pagesize}`);
};
//获取展览预览链接id
export const getPreview = (projectId: number | string) => {
  return axios.get<any>(`api/project/preview/${projectId}/0`, {});
};
//获取展览预览链接id 是否有效
export const checkPreview = (projectId: number | string, previewId: number | string) => {
  return axios.get<any>(`api/project/checkPreview/${projectId}/${previewId}/0`, {});
};
//强制刷新展览预览链接
export const previewUpdate = (projectId: number | string) => {
  return axios.get<any>(`api/project/preview/${projectId}/0`, {});
};
